import { PORT3 } from '@/api/config/servicePort';
import http from '@/api';
import { PositionInterface } from '@/api/interface/dept/position';
import { PublicParams } from '@/api/interface/publicParams';
/**
 * @name 岗位
 */

/** 保存 */
export const positionSave = (params: PositionInterface.ReqSave) => {
  return http.post(PORT3 + `/position/v1/save`, params);
};

/** 查询树结构所有岗位 */
export const positionListFindAllByTerr = () => {
  return http.get<PositionInterface.ResListByTree[]>(PORT3 + `/position/v1/listFindAllByTerr`);
};

/** 查询树结构(平铺后)所有岗位 */
export const positionListFindFlattenTree = () => {
  return http.get<PositionInterface.ResListByTree[]>(PORT3 + `/position/v1/listFindFlattenTree`);
};

/** 修改状态 */
export const positionChangeStatus = (params: PublicParams.ReqStatus) => {
  return http.post(PORT3 + `/position/v1/changeStatus`, params);
};

/** 获取平铺树结构 */
export const positionListFindFlattenTreeByDeptId = (params: PositionInterface.ReqFindByDeptId) => {
  return http.get<PositionInterface.ResListByTree[]>(PORT3 + `/position/v1/ListFindFlattenTreeByDeptId`, params);
};

/** 根据部门id查询岗位树结构 */
export const positionListFindTreeByDeptId = (params: PositionInterface.ReqFindByDeptId) => {
  return http.get<PositionInterface.ResListByTree[]>(PORT3 + `/position/v1/listFindTreeByDeptId`, params);
};

/** 删除 */
export const positionDelete = (params: PublicParams.ReqId) => {
  return http.get(PORT3 + `/position/v1/delete/${params.id}`);
};
